package com.cloud.basic.feign.say;

import org.apache.cxf.endpoint.Client;
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
 
public class WsClientUtil {
 
    /**
     * 调用webservice服务
     * @param wsdUrl 服务地址
     * @param operationName 方法名称
     * @param params 参数
     * @return 服务响应结果
     */
    public static String callWebService(String wsdUrl, String operationName, Object... params){
        JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
        Client client = dcf.createClient(wsdUrl);
        try {
            Object[] objects = client.invoke(operationName, params);
            return objects[0].toString();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "";
    }
}